Skip to content

feat: Support adding identities to select placement attributes#35

Merged
rmi22186 merged 10 commits into
developmentfrom
feat/SQDSDKS-7186-add-all-identities
Jun 20, 2025
Merged

feat: Support adding identities to select placement attributes#35
rmi22186 merged 10 commits into
developmentfrom
feat/SQDSDKS-7186-add-all-identities

Conversation

@rmi22186

Copy link
Copy Markdown
Collaborator

Summary

We want to add all user identities to the attributes that get passed to selectPlacements

Testing Plan

Added unit tests. Tested in local app also.

@rmi22186 rmi22186 requested a review from alexs-mparticle June 16, 2025 12:51
Comment thread src/Rokt-Kit.js
Comment thread src/Rokt-Kit.js Outdated
Comment on lines +190 to +193
filteredAttributes = addIdentityAttributes(
filteredAttributes,
filteredUser
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're merging all the different user attributes below, so I think instead of mutating the existing filtered attributes, we should create a new object that will be merged below. I think this would make logging and debugging easier in the future.

Also, it looks like you're just adding the user identities into the select placement attributes so you really don't need to modify the filtered attributes (i think).

You can just pull the identities out the of the user and just add them into the select placements attributes.

        var filteredUserIdentities = filteredUser.getUserIdentities().userIdentities;

        // Then below:
        var selectPlacementsAttributes = mergeObjects(
            filteredAttributes,
            filteredUserIdentities,
            optimizelyAttributes,
            {
                mpid: mpid,
            }
        );

Comment thread src/Rokt-Kit.js Outdated
* @param {Object} filteredUser - The filtered user object containing identities
* @returns {Object} The attributes object with added identities
*/
function addIdentityAttributes(attributes, filteredUser) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose of this code change is to extract the user identities into the selectPlacement attributes, this function should a wrapper around filteredUser.getUserIdentities().userIdentities that simply returns the identities to be merged later.

It shouldn't be mutating the attributes at all, which can lead to side effects.

Comment thread src/Rokt-Kit.js
Comment thread test/src/tests.js Outdated
.getMPID()
.should.equal('123');
window.mParticle.forwarder.filters.filteredUser
.getMPID().should.equal('123');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this linting error.

Comment thread test/src/tests.js
Comment thread test/src/tests.js Outdated
Comment thread test/src/tests.js Outdated
Comment thread test/src/tests.js Outdated
Comment thread test/src/tests.js Outdated
Comment thread test/src/tests.js Outdated
};
});

it('should handle case when userIdentities is null but userAttributes exist', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should handle case when userIdentities is null but userAttributes exist', async () => {
it('should send userAttributes if userIdentities is null but userAttributes exists', async () => {

rmi22186 and others added 4 commits June 17, 2025 10:16
Co-authored-by: Alex S <49695018+alexs-mparticle@users.noreply.github.com>
@rmi22186 rmi22186 merged commit 7e114d1 into development Jun 20, 2025
4 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 14, 2025
# [1.6.0](v1.5.0...v1.6.0) (2025-07-14)

### Bug Fixes

* Prevent mutation of global launcherOptions during initialization ([#36](#36)) ([0f36fac](0f36fac))

### Features

* Add Extensions to Rokt Kit ([#26](#26)) ([73e9696](73e9696))
* Support adding identities to select placement attributes ([#35](#35)) ([f9595ea](f9595ea))
@alexs-mparticle alexs-mparticle deleted the feat/SQDSDKS-7186-add-all-identities branch March 25, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants